package com.ruoyi.client.controller;

import com.ruoyi.client.pojo.form.ChapterForm;
import com.ruoyi.client.pojo.form.NovelsPageForm;
import com.ruoyi.client.pojo.vo.ChapterVo;
import com.ruoyi.client.pojo.vo.NovelVo;
import com.ruoyi.client.service.NovelService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Anonymous//允许匿名访问
@CrossOrigin
@RestController
@RequestMapping("/novels")
public class NovelController extends BaseController {
    @Resource
    private NovelService novelService;

    @GetMapping("/page")
    public TableDataInfo page(NovelsPageForm form){
        startPage();
        List<NovelVo> list = novelService.page(form);
        return getDataTable(list);
    }

    @GetMapping("/chapter")
    public TableDataInfo chapter(ChapterForm chapterForm){
        startPage();
        List<ChapterVo> chapterVoList=novelService.listChapter(chapterForm);
        return getDataTable(chapterVoList);
    }
}
